home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz Kr0nlcKLeZ 1 / HaCKeRz Kr0nlcKLeZ.iso / chibacity / retal.txt < prev    next >
Encoding:
Text File  |  1996-04-22  |  14.0 KB  |  294 lines

  1.                     Computer  Virus  Developments  Quarterly
  2.  
  3.                     Retaliating Against Integrity Checkers
  4.                             A Retaliating Virus
  5.  
  6.      A Retaliating Virus is a virus which can retaliate
  7. against anti-viral measures which might be in place to
  8. frustrate its attempts to replicate within a computer sys-
  9. tem.  Such viruses may prove to be as much of a setback
  10. to non-scanning techniques for catching viruses as self-
  11. mutating viruses have been to scanners.
  12.      Here we will present the functional details of how a
  13. retaliatory virus might work on a PC which has basic
  14. anti-viral protection installed on it.  This virus is called
  15. simply RETALIATOR.  (Source code for
  16. RETALIATOR is included on the disk received by paid
  17. subscribers only.) To understand how RETALIATOR
  18. works, let's first look at a simple virus which infects
  19. EXE files.  A flow chart for such a virus looks something
  20. like this:
  21.  
  22.  
  23.           EXE file
  24.           loaded by
  25.           operating
  26.            system
  27.              |
  28.              |
  29.              |
  30.           Virus gains
  31.           control of
  32.            the CPU
  33.              |
  34.              |
  35.              |
  36.           Search for
  37.           uninfected
  38.            EXE file
  39.              |
  40.              |
  41.              |
  42.              |
  43.              |
  44.           Infect file
  45.              |
  46.              |
  47.              |
  48.           Pass con-
  49.           trol to host
  50.            program
  51.  
  52. Such a virus is normally caught by anti-viral software in
  53. three ways:
  54.  
  55. 1)   A scanner may know the signature of such a virus, and
  56.      locate it in a piece of suspect software, and flag the
  57.      user as to its presence.
  58. 2)   A memory-resident behavior-checker could be look-
  59.      ing for suspicious activity, and catch the virus in the
  60.      act of replication.
  61. 3)   An integrity checker could determine that a file which
  62.      this virus infected had been changed.  Then, either
  63.      simple user awareness, or a type of dynamic scanning
  64.      might be employed to track down the original source
  65.      of the virus, once its spread was detected.
  66.  
  67.      A virus which retaliates against active measures will
  68. attempt to make the user regret using methods (2) or (3)
  69. to secure his system.  A number of authors have made
  70. much of the the inability of viruses to fool various anti-
  71. viral measures like integrity checkers.' This is a rather
  72. difficult task if the integrity checker is properly imple-
  73. mented.  However, a virus need not fool the anti-virus
  74. measure.  It can just get mean, like a cornered animal
  75. fighting for its life.  It can do that if it is not detected by a
  76. scanner and gains control of the CPU at least once.  Such
  77. behavior could prove to be as detrimental to the integrity
  78. checker approach as if viruses could easily fool them.  It
  79. will discourage people from using anything more than a
  80. scanner when they are already not inclined to do it.
  81.      In this article, we will demonstrate just how easy it is
  82. to implement such anti-anti-viral measures.
  83.  
  84.      Memory-resident anti-viral behavior checkers
  85. generally hook interrupts 21H and 13H, among others,
  86. and monitor them for suspicious activity.  They can then
  87. warn the user that something dangerous is taking place
  88. and allow the user to short-circuit the operation.  Typical-
  89. ly, suspicious activity includes attempts to overwrite the
  90. boot sector, modify executable files, or terminate and
  91. stay resident.
  92.      The real shortcoming of such memory-resident anti-
  93. viral programs is simply that they are memory resident-
  94. sitting right there in RAM.  And just as virus scanners
  95. typically search for viruses which have gone memory-
  96. resident, a virus could search for anti-virus programs
  97. which have gone memory-resident.  There are only a
  98. relatively few memory-resident anti-virus programs on
  99. the market, so scanning for them is a viable option.
  100.      Finding scan strings for anti-virus programs is easy.  
  101. Just load the program into memory and use MAPMEM
  102. or some similar program to find one in memory and learn
  103. what interrupts are hooked.  Then use DEBUG to look
  104. through the code and find a suitable string of 10 or 20
  105. bytes.  Incorporate this string into a memory search
  106. routine in the virus, and it can quickly and easily find the
  107. anti-virus program in memory.  The process can be sped
  108. up considerably if you write a fairly smart search
  109. routine.  Using such techniques, memory can be scanned
  110. for the most popular memory-resident anti-viral
  111. software very quickly.  If need be, even expanded or
  112. extended memory could be searched.
  113.      Once the virus has located an anti-virus routine in
  114. memory, it has a number of options.  It may simply go
  115. dormant.  The virus will then stop replicating as long as
  116. the anti-virus routine is in memory watching it.  Yet if the
  117. owner of the program turns his virus protection off, or
  118. passes the program along to anyone else, the virus will
  119. reactivate.  In this way, someone using anti-viral
  120. software becomes a carrier who spreads a virus while his
  121. own system has no symptoms.
  122.      Alternatively, the virus could simply trigger a logic
  123. bomb when it detects the anti-virus routine, and trash the
  124. hard disk, CMOS, or what have you.  Such a logic bomb
  125. would have to be careful about using DOS or BIOS
  126. interrupts to do its dirty work, as they may be hooked by
  127. the anti-viral software.  A number of options are avail-
  128. able: the virus could search the ROM BIOS for the initial
  129. interrupt 13H vector, or use detailed knowledge of the
  130. memory resident software it detected to unhook the
  131. necessary vectors.  Alternatively, it could incorporate a
  132. routine to do direct disk 1/0.  While doing direct disk 1/0
  133. may be somewhat cumbersome, the code to do it is fairly
  134. easily obtainable, either from an AT Technical Reference
  135. manual or using a good disassembler on your own BIOS
  136. ROM, and a dedicated routine to trash a hard disk would
  137. not consume an unreasonable amount of space.
  138.      Finally, the virus could play a more insidious trick.  
  139. Suppose an anti-virus program had hooked interrupt
  140. 13H.  If the virus scanned and found the scan string in
  141. memory, it could also locate the interrupt 13H handler,
  142. even if layered in among several other TSR'S.  Then,
  143. rather than reproducing, the virus could replace that
  144. handier with something else in memory, so that the anti-
  145. virus program itself would damage the hard disk.  For
  146. example, one could easily write an interrupt 13H handier
  147. which waited 15 minutes, or an hour, and then incre-
  148. mented the cylinder number on every fifth write.  This
  149. would make a horrible mess of the hard disk pretty
  150. quickly, and it would be real tough to figure out why it
  151. happened.  Anyone checking it out would probably tend
  152. to blame the anti-viral software.
  153.      Of course, mixtures of these methods are also pos-
  154. sible.  For example, a virus could remain quiet until a
  155. certain date, and then launch a destructive attack.
  156.      The virus we are studying, RETALIATOR, in the
  157. configuration described here, is set up to pick on a
  158. popular anti-viral package, as noted in the source code.  
  159. The normal install procedure of this anti-viral package
  160. will set one's system up to put a program VSAFE into
  161. memory at boot-up.  This program hooks a number of
  162. interrupts and actively maintains checksums of ex-
  163. ecutable files, alerting the user to a change before a
  164. program is executed.  RETALIATOR easily detects it in
  165. memory and jumps to a routine which announce,-
  166. "RETALIATOR has detected resident anti-viral
  167. software.  TRASHING HARD DISK!" and proceeds to
  168. simulate the disk activity one might expect when a hard
  169. disk is being systematically wiped out.  RETALIATOR
  170. was also written in such a way that it is easy to modify
  171. and add scan strings for different memory-resident anti-
  172. viral packages.
  173.  
  174.  
  175.      Designing a virus which can retaliate against integrity
  176. checkers is a bit more complicated, since they don't
  177. reside in memory.  It usually isn't feasible to scan an
  178. entire hard disk for an integrity checker from within a
  179. virus.  The amount of time and disk activity it would take
  180. would be a sure cue to the user that something funny was
  181. going on.  Since the virus should remain as unnoticeable
  182. as possible-unless it gets caught-another method of
  183. dealing with integrity checkers is desirable.
  184.      One possible way to locate a non-resident anti-virus
  185. program in a discrete fashion is to look for it in its default
  186. location.  Although such a technique is obviously not
  187. foolproof, most users (stupidly) never think to change
  188. even the default directory in the install sequence.  Such ,
  189. default search could be relatively fast, and it would allow
  190. the virus to knock out the system the first time it gained
  191. control.
  192.      Such methods are unreliable at best, though.  If imple-
  193. mented, they still need some kind of backup approach,
  194. since a simple directory name-change will thwart them.  
  195. Apart from such scanning, a virus could check for chan-
  196. ges it has made to other executables and take action in
  197. the event that such changes get cleaned up.  Of course,
  198. such an approach means that the virus must gain control
  199. of the CPU, make some changes, and release control of
  200. the CPU again.  Only once it gains control a second time
  201. can it check to see if those changes are still on the
  202. system.  Obviously, there is a certain amount of risk in
  203. any such operation.  In between the first and second
  204. executions of the virus, the anti-viral software could
  205. detect the change which the virus made, and track down
  206. the virus and remove it.  Then there would be no second
  207. execution in which the virus gains control, notices its
  208. efforts have been thwarted, and then retaliates.
  209.      If, however, we assume that the virus has successful-
  210. ly determined that there is no dangerous memory-resi-
  211. dent software in place, then it can go out and modify files
  212. without fear of being caught in the act.  The most
  213. dangerous situation that such a virus could find itself ir
  214. would be if an integrity shell checked the checksum of
  215. every executable on a disk both before and after a pro-
  216. gram was executed.  Then it could pinpoint the exact time
  217. of infection, and nail the program which last executed.  
  218. This is just not practical for most users, though, because
  219. it takes too long.  Norally, an integrity checker is an
  220. occasional affair.  You run it once in a while, or you run
  221. it automatically from time to time.
  222.      So your integrity checker has just located an EXE file
  223. that has changed.  Now what? Disassemble it and find out
  224. what's going on? Not likely.  Of course you can delete it
  225. or replace it with the original from your distribution
  226. disks.  But with a retaliating virus you really must find
  227. the source immediately.  If you have a smart enough
  228. scanner that came with your integrity shell, you might be
  229. able to create an impromptu scan string and track down
  230. the source (if the virus didn't take precautions against
  231. that).  If anything less than a complete clean-up occurs at
  232. this stage, though, one must live with the idea that this
  233. virus will execute again, sooner or later.
  234.      If the virus you're dealing with is a smart, retaliating
  235. virus, this is an ominous possibility.  There is no reason
  236. that a virus could not hide a list of infected files some-
  237. where on a disk, and check that list when it is executed.  
  238. Are the files which were infected still infected? No?
  239. Something's messing with the virus.  Take action.  Trash
  240. that disk now!
  241.      Alternatively, the virus could leave a portion of code
  242. in memory which just sits there guarding a newly in-
  243. fected file.  If anything attempts to modify or delete the
  244. file, this sentry goes into action, causing whatever
  245. damage it wants to.  And the virus is still hiding in your
  246. backup.
  247.      Although these scenarios are not very pretty, and
  248. we'd rather not talk about them, any of them are rather
  249. easy to implement.  The RETALIATOR virus, for ex-
  250. ample, maintains a simple record of the last file infected
  251. in Cylinder 0, Head 0, Sector 2 on the currently logged
  252. hard disk. (Note that RETALIATOR only replicates on
  253. hard disks.  It is dormant on floppies.) This sector, which
  254. resides right after the master boot record is normally not
  255. used, so the virus is fairly safe in taking it over.  When the
  256. virus executes, it checks whatever file name is stored
  257. there to see if it is still infected.  If so, it infects a new file,
  258. and stores the new file name there.  If the file it checks is
  259. missing, it just infects a new file.  However if the file
  260. which gets checked is no longer infected, it proceeds to
  261. execute its simulated "TRASHING HARD DISK!"
  262. routine.  Such a file-checking routine could easily be
  263. modified to check multiple files.  Of course, one would
  264. have to be careful not to implement a trace-back feature
  265. into the checking scheme.
  266.      To avoid being caught by a sophisticated scanner/in-
  267. tegrity checker, RETALIATOR is polymorphic.  The
  268. virus has 512 nominally different signatures, and two
  269. ,which are totally different.  Each time it replicates, it
  270. changes its signature.  
  271.  
  272. In conclusion, viruses which retaliate against anti-
  273. viral software are rather easy to create.  They have the
  274. potential to lie dormant for long periods of time, or turn
  275. into devastating logic bombs.  The only safe way to
  276. defend a system against this class of viruses is by using
  277. a smart scanner which can identify such viruses without
  278. ever executing them.  For all its nasty habits,
  279. RETALIATOR could be easily spotted by a signature
  280. analyzing scanner which used thoughtful scan strings
  281. based on a disassembly of the virus.
  282.      Viruses such as RETALIATOR could, in time, make
  283. it very dangerous to use simple integrity checkers or
  284. TSR's to catch viruses while giving them control of the
  285. CPU.  RETALIATOR is by no means the most sophisti-
  286. cated or creative example of such a virus.  It is only a
  287. simple, demonstrable example of what can be done.  If
  288. anti-viral developers continue to turn away from scan-
  289. ners-as they seem to be doing-rather than developing
  290. a new generation of smarter scanning technology, we
  291. might end up being faced with the situation of really
  292. needing a smart scanner, and being faced with the pos-
  293. sibility that it won't be available for one or two years.
  294.